<script type="text/javascript">
function save() {
	var parm = $('#editCommodityShowForm').serialize();
	var url = create_url('parkorgan-saveBatch');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
		sys_submiting_close();
			if ('success' == result) {
				sys_msg('操作成功!');
				sys_load_handle('parkorgan');
			}else if('parameter_error' == result){
				sys_msg('序号重复!');
			}
		}
	});
}

function selectCommodity() {
		var url = create_url('parkorgan-batchOrganInit');
		var index = $("#index").val();
		var parm = {'index': index};
		$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'750px',height:'500px', open:true});
}

function checkedSort(b){
	var sort = b.val();
	console.log(sort);
	var i = 0;
	$("#newTable").find(".sort").each(function(){
		if($(this).val() != '' && sort != '' && $(this).val() == sort){
		i++;
		}
	});
	if(i >=2 ){
		sys_msg("序号重复!");
		b.val('');
	}
}
function checked(){
	var flag=true;
	$("#newTable input[type='text']").each(function(){
		if($(this).val().length==0){
			alert("必须填写排行序号");
			flag=false;
			return false;
		}
	});
	if(flag){
		save();
	}
}
</script>
<div class="widget" style="float:left; width:720px;">
	<div class="widget-header">
		<h3 class="title"><i class="fontello-icon-th-list-1"></i>批量添加</h3>
	</div>
	<div class="input-group">
		<span class="btn-group">
			<input type="hidden" id="code" name="code" value="${(pc.code)!''}"/>
			<input type="hidden" id="cc" name="cc" value="${(pc.cc)!''}"/>
			<input type="text" id="name" name="name" value="${(pc.name)!''}" readonly="readonly"/>
			<button class="btn btn-primary" onclick="javascript: selectCommodity();" title="选择机构" type="button"><i class="icon-search"></i></button>
			<button class="btn btn-danger" onclick="javascript: $('#name').val(''); $('#cc').val('');" title="重置" type="button"><i class="icon-remove"></i></button>
		</span>
	</div>
	<form id="editCommodityShowForm">
		<table id="newTable" cellpadding="1" cellspacing="1" class="table table-bordered">
			<tr>
				<th>公司名称</th>
				<th>序号(序号越大排列越前)</th>
				<th>操作</th>
			</tr>
		</table>
		<a href="javascript:;" class="btn btn-info" onclick="javascript:checked();"><i class="fontello-icon-mail-4"></i>&nbsp;保&nbsp;&nbsp;存</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href="javascript:;" class="btn btn-info" onclick="javascript:sys_load_handle('parkorgan');"><i class="fontello-icon-block"></i>&nbsp;取&nbsp;&nbsp;消</a>
	</form>
</div>
<input id="index" type="hidden" value="0"/>